package com.jevons.geo_lib.op_history;


import com.jevons.geo_lib.utils.StringUtils;
import com.mapbox.geojson.Point;

/**
 * Copyright 2020 JxGIS
 *
 * @file BianjieHistory
 * @auth linaisheng
 * Created on 2020/12/2.
 * Description：
 */
public class BianjieHistory implements OperationHistory {


    public enum Type {
        AddPoint,
        MovePoint,
        DeletePoint
    }

    protected String featureTempId;
    protected Type type;

    private int[] coordinatesIndex;

    private Point oldPoint;
    private Point newPoint;

    private String commonKey;


    public BianjieHistory(Type operateType, String featureTempId, int[] coordinatesIndex,
                          Point oldPoint) {
        this(operateType, featureTempId, coordinatesIndex, oldPoint, null);
    }

    public BianjieHistory(Type operateType, String featureTempId, int[] coordinatesIndex,
                          Point oldPoint, Point newPoint) {
        this.type = operateType;
        this.featureTempId = featureTempId;
        this.coordinatesIndex = coordinatesIndex;
        this.oldPoint = oldPoint;
        this.newPoint = newPoint;
    }


    public void setCommonKey(String commonKey) {
        this.commonKey = commonKey;
    }

    public boolean isCommonPoint() {
        return StringUtils.isNotEmpty(commonKey);
    }

    public String getCommonKey() {
        return commonKey;
    }

    public String getFeatureTempId() {
        return featureTempId;
    }

    public Type getType() {
        return type;
    }

    public int[] getCoordinatesIndex() {
        return coordinatesIndex;
    }

    public Point getOldPoint() {
        return oldPoint;
    }

    public Point getNewPoint() {
        return newPoint;
    }

    @Override
    public String getOperateFlag() {
        return "op_bianjie";
    }

    @Override
    public DrawType getDrawType() {
        return DrawType.Bianjie;
    }
}
